#include "EntityCloud.h"

CEntityCloud::CEntityCloud(int startPositionX, int startPositionY, int indexSprite, int speed,
						   int timeBetweenCloud, bool active):
			startPositionX(startPositionX), startPositionY(startPositionY),
			timeBetweenCloud(timeBetweenCloud), timeStopCloud(2)

{
	assert(indexSprite>=0);

	this->currentPosX=startPositionX;
	this->currentPosY=startPositionY;
	this->indexSprite=indexSprite;
	this->speed=speed;
	this->collisionCost=0;
	this->active=active;
	this->side=eSideNeutral;

	//we don't use those two variables
	this->previousPosX=0;
	this->previousPosY=0;
}


CEntityCloud::~CEntityCloud(void)
{
}

void CEntityCloud::update(void)
{
	//if it's time to display the cloud
	if((int)HAPI->GetTime()>=timeStopCloud+timeBetweenCloud)
	{
		//if the cloud still in the screen
		if(currentPosY<=VIS.getScreenHeight()-speed)
		{
			currentPosY+=speed;
		}
		else //the cloud out of the screen
		{
			timeStopCloud=HAPI->GetTime();
			currentPosY=startPositionY;
			if(currentPosX+300>=VIS.getScreenWidth())
			{
				currentPosX=startPositionX;
			}
			else
			{
				currentPosX+=300;
			}
		}
			
	}
}

void CEntityCloud::render(void)
{
	VIS.displaySprite(this->currentPosX,this->currentPosY,this->indexSprite,true);
}
int CEntityCloud::getStartPositionX(void) const
{
	return this->startPositionX;
}
int CEntityCloud::getStartPositionY(void) const
{
	return this->startPositionY;
}
int CEntityCloud::getTimeBetweenCloud(void) const
{
	return this->timeBetweenCloud;
}
int CEntityCloud::getTimeStopCloud(void) const
{
	return this->timeStopCloud;
}

void CEntityCloud::setStartPositionX(int startPositionX)
{
	this->startPositionX=startPositionX;
}
void CEntityCloud::setStartPositionY(int startPositionY)
{
	this->startPositionY=startPositionY;
}
void CEntityCloud::setTimeBetweenCloud(int timeBetweenCloud)
{
	this->timeBetweenCloud=timeBetweenCloud;
}
void CEntityCloud::setTimeStopCloud(int timeStopCloud)
{
	this->timeStopCloud=timeStopCloud;
}